package com.qdu.controller;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.qdu.entity.Homemessage;
import com.qdu.entity.Users;
import com.qdu.service.HomemessageService;

@Controller
@RequestMapping("/homemessage")
public class HomemessageController {
	
	@Autowired
	private HomemessageService homeService;
	
	
	@GetMapping("/comment")
	public String comment( String messageUid,String messageHid,String Hmessage,HttpSession session) {
		Users user=(Users)session.getAttribute("sessionuser");
		String Uid2=user.getUid();
		Homemessage comment = new Homemessage();
		comment.setUid(messageUid);
		comment.setUid2(Uid2);
		comment.setHid(messageHid);
		comment.setHmessage(Hmessage);
		homeService.addmessage(comment);
		return "index";
	}
    @PostMapping("/delete")
    @ResponseBody
    public void comment(String Uid,String Uid2,String Hid) {
           homeService.deletemessage(Uid, Uid2, Hid);
    }
	
}
